package com.base.caselib.utils;

import android.support.annotation.NonNull;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import static com.base.commonlib.utils.DeteUtil.ToUpper;
import static com.base.commonlib.utils.DeteUtil.dayToUppder;
import static com.base.commonlib.utils.DeteUtil.monthToUppder;

/**
 * Created by weikailiang on 2019/12/14.
 */

public class Utils {
    @NonNull
    public static String GetUpperTime(@NonNull String time) {
        String result = "";
        try {
            int index = time.indexOf(" ");
            String nian = time.substring(0, index);
            String[] ss = nian.split("-");
            String year = ToUpper(Integer.parseInt(ss[0]));
            String month = monthToUppder(Integer.parseInt(ss[1]));
            String day = dayToUppder(Integer.parseInt(ss[2]));
            result = year + "年" + month + "月" + day + "日";
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return result;
    }
    public static String GetUpperdate(String time){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy年MM月dd日HH时mm分");
        try {
            Date t = simpleDateFormat.parse(time);
            return simpleDateFormat2.format(t);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
